package yesjava.news.dao;

import yesjava.news.entity.User;
import yesjava.news.utils.MyDbUtil;

import java.sql.*;
import java.util.Date;
import java.util.List;

public class UserDaoImpl implements UserDao{
    @Override
    public User selectUserByNameAndPassword(String name, String password) {
        String sql = " select * from user where name = ? and password = ? ";
        List<User> users = MyDbUtil.executeQuery(User.class, sql, name, password);
        return (users.size()>0? users.get(0):null);
    }

    @Override
    public User selectUserId(Integer id) {
        String sql = " select * from user where id = ?  ";
        List<User> users = MyDbUtil.executeQuery(User.class, sql, id);
        return (users.size()>0? users.get(0):null);
    }
}
